<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="common :: common('修改密码')">
</head>
<body class="hold-transition register-page">
	<div class="register-box">
		<div class="register-logo">
			<a href="/">&copy;<b>XIXIWAN</b> platform
			</a>
		</div>
		<div class="register-box-body">
			<p class="login-box-msg">修改密码</p>

			<form id="expireForm" action="/expire">
				<div class="form-group">
					<div class="input-group">
						<div class="input-group-addon">
							<i class="fa fa-fw fa-user" aria-hidden="true"></i>
						</div>
						<input type="text" name="username" class="form-control"
							placeholder="账户名">
					</div>
				</div>
				<div class="form-group">
					<div class="input-group">
						<div class="input-group-addon">
							<i class="fa fa-fw fa-lock" aria-hidden="true"></i>
						</div>
						<input type="password" name="originalPassword"
							class="form-control" placeholder="原密码">
					</div>
				</div>
				<div class="form-group">
					<div class="input-group">
						<div class="input-group-addon">
							<i class="fa fa-fw fa-lock" aria-hidden="true"></i>
						</div>
						<input type="password" name="password" class="form-control"
							placeholder="新密码">
					</div>
				</div>
				<div class="form-group">
					<div class="input-group">
						<div class="input-group-addon">
							<i class="fa fa-fw fa-lock" aria-hidden="true"></i>
						</div>
						<input type="password" name="retypePassword" class="form-control"
							placeholder="重新输入密码">
					</div>
				</div>
				<div class="row">
					<div class="col-xs-4 pull-right">
						<button type="submit" class="btn btn-success btn-block btn-flat">
							<i class="fa fa-fw fa-floppy-o" aria-hidden="true"></i> 修改
						</button>
					</div>
					<!-- /.col -->
				</div>
			</form>
		</div>
		<!-- /.form-box -->
	</div>
	<!-- /.register-box -->
	<script type="text/javascript">
		$(function() {
			$('#expireForm').bootstrapValidator({
				message : '这个值是无效的',
				feedbackIcons : {
					valid : 'fa fa-check',
					invalid : 'fa fa-remove',
					validating : 'fa fa-refresh'
				},
				fields : {
					username : {
						validators : {
							notEmpty : {}
						}
					},
					originalPassword : {
						validators : {
							notEmpty : {}
						}
					},
					password : {
						validators : {
							notEmpty : {},
							identical : {
								field : 'retypePassword',
								message : '这两个密码不匹配'
							}
						}
					},
					retypePassword : {
						validators : {
							notEmpty : {},
							identical : {
								field : 'password',
								message : '这两个密码不匹配'
							}
						}
					}
				}
			}).on('success.form.bv', function(e) {
				// Prevent form submission
				e.preventDefault();

				// Get the form instance
				var $form = $(e.target);

				// Get the BootstrapValidator instance
				var bv = $form.data('bootstrapValidator');

				// Use Ajax to submit form data
				$.post($form.attr('action'), $form.serialize(), function(result) {
					if (result.success) {
						window.location.href = "/";
					} else {
						layer.msg(result.errorMsg, {
							icon : 5
						});
					}
				}, 'json');
			});
		});
	</script>
</body>
</html>